package com.xhsj.user.sms.purchase.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhsj.user.sms.purchase.entity.PurchaseUserInfo;
import com.xhsj.user.sms.purchase.entity.TbPurchaseTask;
import com.xhsj.user.sms.purchase.query.PurchaseApplyQuery;
import com.xhsj.user.sms.purchase.vo.FindApplyListVo;
import com.xhsj.user.sms.purchase.vo.PurchaseApplyQueryVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 采购任务表 Mapper 接口
 * </p>
 *
 * @author suxiaolin
 * @since 2020-05-25
 */
@Mapper
public interface TbPurchaseTaskMapper extends BaseMapper<TbPurchaseTask> {

    /**
     * 查询采购任务列表
     * @author 苏小林
     * @date 2020/5/25 13:26
     * @param: page
     * @param: roleList
     * @param: userId
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<com.xhsj.user.sms.purchase.entity.TbPurchaseTask>
     */
    IPage<TbPurchaseTask> findPurchaseTaskList(Page<TbPurchaseTask> page, @Param("userId") String userId,
                                               @Param("status") String status, @Param("entity") TbPurchaseTask entity);

    IPage<TbPurchaseTask> queryPurchaseTaskList(Page<TbPurchaseTask> page, @Param("status") String status, @Param("entity") TbPurchaseTask entity);

    PurchaseApplyQueryVo getPurchaseTaskById(@Param("id") String id);

    TbPurchaseTask getPurchaseTaskInfoById(@Param("id") String id);

    void delById(@Param("id") String id);

    void delContractInfoById(@Param("id") String id);

    int updateCreateBy(@Param("userId") Integer userId, @Param("dataId") String dataId);

    int updateProposerIdByDataId(@Param("userId") Integer userId, @Param("dataId") String dataId);

    int updateUserIdById(@Param("userId") Integer userId, @Param("dataId") String dataId);

    IPage<FindApplyListVo> findPurchaseTask(IPage<TbPurchaseTask> page, @Param("entity") PurchaseApplyQuery entity);

    // 通过任务id查询子任务数量
    int getSubTaskCountByTaskId(@Param("id") String id);

    // 删除采购任务
    int delPurchaseTaskById(@Param("id") String id);

    // 删除采购订单
    int delPurchaseOrderById(@Param("id") String id);


    List<PurchaseUserInfo> findPurchaseUserInfo();

}
